package com.fzhucc.modules.appletShow.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set;

/**
 * 服务项目
 *
 * @since 2023-02-07
 */
@Entity
@Data
@Table(name = "cms_service")
public class CmsService implements Serializable {

    public static final String CLASSIFY_INTELLECTUAL_PROPERTY = "知识产权";

    public static final String CLASSIFY_FINANCIAL_FINANCING = "金融融资";

    public static final String CLASSIFY_SPECIALIZATION_NOVELTY = "专精特新";

    public static final String CLASSIFY_ENTREPRENEURSHIP_INCUBATION = "创业孵化";

    public static final String CLASSIFY_TECHNOLOGY = "技术研发";

    public static final String CLASSIFY_OTHER = "其他服务";


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Integer id;

    /**
     * 有效开始时间
     */
    private Timestamp startTime;

    /**
     * 有效截止时间
     */
    private Timestamp endTime;

    private String type;

    @ElementCollection
    @JoinTable(name = "cms_service_tags")
    private Set<String> tags;

    @ElementCollection
    @JoinTable(name = "cms_service_types")
    private Set<String> types;

    /**
     * 收费标准
     */
    private String price;

    @Column(name = "`name`", nullable = false)
    @NotBlank
    @ApiModelProperty(value = "名称")
    private String name;

    @Column(name = "`img`")
    @ApiModelProperty(value = "banner图片")
    private String img;

    @Column(name = "`intro`", columnDefinition = "TEXT")
    @ApiModelProperty(value = "简介")
    private String intro;

    @Column(name = "`is_show`", nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否展示小程序")
    private Integer isShow;

    @Column(name = "`sort`")
    @ApiModelProperty(value = "显示顺序")
    private Integer sort;

    @Column(name = "`create_user_id`")
    @ApiModelProperty(value = "创建者user_id")
    private Long createUserId;

    @Column(name = "`level`")
    @ApiModelProperty(value = "项目等级")
    private Integer level;

    @Column(name = "`is_push`")
    @ApiModelProperty(value = "是否推送  服务项目才有推送 默认不推送")
    private Integer isPush;

    @Column(name = "`classify`")
    @ApiModelProperty(value = "服务分类")
    private String classify;

    public void copy(CmsService source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
